<?php
Yii::import('ext.gapi');

class AnalyticsCommand extends CConsoleCommand
{
	public function run($args){
		//0.Config
		$gapiEmail = 'jose.pompilla@itegracion.com';
		$gapiPassword = 'tacarotacaro';
		$gapiId = 57461426;
		
		//1. Recolectar Datos de Google Analytics		
		$ga = new gapi($gapiEmail,$gapiPassword);
		$ga->requestReportData($gapiId,array('pagePath'),array('visitors'),array('-pagePath'),'date=='.$args[0]);
		foreach($ga->getResults() as $item)
		{
			echo $item.": ".$item->getVisitors()."\n";
		}
		
		echo "Hecho!\n";
	}
}